﻿using University.Workshop.Presenters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Data;
using University.Workshop.Tests.Mocks;
using University.Workshop.Business;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    
    
    
    [TestClass()]
    public class PresenterGiftsTest
    {


        private TestContext testContextInstance;

       
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

       
       
        [TestMethod()]
        public void GenerateReportTestValid()
        {
            GiftMockView view = new GiftMockView();
            PresenterGifts target = new PresenterGifts(view);
            view.ValidDatesExistGift();
            bool actual = PresenterGifts.GenerateReport();
            Assert.AreEqual(true, File.Exists("reporteCompraTodos.pdf"));
        }

       
        [TestMethod()]
        public void DeleteGiftTestValid()
        {
            GiftMockView view = new GiftMockView();
            PresenterGifts target = new PresenterGifts(view);
            view.ValidNameFromTable();
            bool actual = target.DeleteGift();
            Assert.AreEqual(true, actual);
        }

        
        [TestMethod()]
        public void ChargeDataTableTestValid()
        {
            GiftMockView view = new GiftMockView();
            PresenterGifts target = new PresenterGifts(view);
            bool actual = target.ChargeDataTable();
            Assert.AreNotEqual(0, view.TableGifts.Rows.Count);         
        }


        [TestMethod()]
        public void AddGiftTestValid()
        {
            GiftMockView view = new GiftMockView();
            PresenterGifts target = new PresenterGifts(view);
            view.ValidDatesGift();
            view.PriceGift = "123.4";
            bool actual = target.AddGift();
            DataAccess.DataAccessGifts.DeleteDataGiftByName("premio1");
            Assert.AreEqual(true, actual);

        }
        [TestMethod()]
        public void SearchGiftForClientTestValid()
        {

            string actual = GiftsControl.GetGiftByPricesAndClient("101010", "100000000");
            string expected = "Los premios que puede elejir el cliente por su compra son: PLANCHA2, ";
            Assert.AreEqual(expected, actual);

        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void ExistGiftInvalidTest()
        {
            GiftMockView view = new GiftMockView();
            PresenterGifts target = new PresenterGifts(view);
            view.ValidDatesExistGift();
            bool actual = target.AddGift();


        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void InvalidNameTest()
        {
            GiftMockView view = new GiftMockView();
            PresenterGifts target = new PresenterGifts(view);
            view.InvlaidName();
            bool actual = target.AddGift();


        }
        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void InvalidPriceTest()
        {
            GiftMockView view = new GiftMockView();
            PresenterGifts target = new PresenterGifts(view);
            view.InvalidPrice();
            bool actual = target.AddGift();


        }
    }
}
